<template>
  <div id="login" v-show="isShowLogin">
    <div class="mask">
      <div class="mini">
        <div class="mini-close">
          <el-button
            plain
            type="primary"
            size="small"
            icon="el-icon-close"
            circle
            @click="closeLogin"
          ></el-button>
        </div>

        <div class="header">登录账号</div>

        <el-input
          placeholder="请输入手机号"
          suffix-icon="el-icon-mobile-phone"
          type="phone"
          v-model="userLogin.phone"
          class="phone"
        >
        </el-input>
        <el-input
          placeholder="请输入密码"
          v-model="userLogin.password"
          show-password
          class="password"
        ></el-input>
        <div class="button-group">
          <el-button type="primary" round @click="login">登录</el-button>
          <el-button native-type="reset" round>清空</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "Login",
  data() {
    return {
      userLogin: {
        phone: "",
        password: "",
      },
    };
  },
  computed: {
    ...mapState({
      isShowLogin: (state) => state.user.isShowLogin,
    }),
  },
  methods: {
    closeLogin(){
      this.$store.dispatch("showLogin",false)
    },
    login() {
      if (this.userLogin.phone == null || this.userLogin.password == null) {
        return false;
      }
      this.$store.dispatch("login", this.userLogin);
    },
  },
};
</script>

<style lang="less">
#login {
  .mask {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
  }
  .mini {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    width: 520px;
    border-radius: 8px;
    -webkit-box-shadow: 0 0 6px rgb(0 0 0 / 10%);
    box-shadow: 0 0 6px rgb(0 0 0 / 10%);
    padding: 20px 20px 20px 20px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    background-color: #fff;
    background-image: url(https://s1.hdslb.com/bfs/seed/jinkela/short/mini-login/img/22_open.72c00877.png),
      url(https://s1.hdslb.com/bfs/seed/jinkela/short/mini-login/img/33_open.43a09438.png);
    background-position: 0 100%, 100% 100%;
    background-repeat: no-repeat, no-repeat;
    background-size: 14%;
    position: relative;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    .header {
      font-size: 18px;
      color: #505050;
    }
    .mini-close {
      position: absolute;
      right: 15px;
      top: 15px;
      i {
        font-weight: bold;
      }
    }
    .phone {
      margin-top: 20px;
    }
    .password {
      margin-top: 20px;
    }
    .button-group {
      margin-top: 20px;
      display: flex;
      justify-content: center;
    }
  }
}
</style>